/*
 * @Author: your name
 * @Date: 2022-02-24 19:15:49
 * @LastEditTime: 2022-02-28 23:05:44
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \web\node个人博客\blog_web\src\util\localstorage.js
 */

const db = {
  // 保存值到localstorage中
  save(key, value) {
    localStorage.setItem(key, JSON.stringify(value))
  },
  // 获取localstorage中的值
  get(key, defaultvalue = null) {
    return JSON.parse(localStorage.getItem(key)) || defaultvalue
  },
  // 移除localstoage中的值
  remove(key) {
    localStorage.removeItem(key)
  },
  // 清空值
  clear() {
    localStorage.clear()
  }
}

export default db
